package thread.test2;


import java.util.concurrent.*;

public class CallableTest implements Callable<String>{

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        //创建一个有10个线程的线程调度服务
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
        for (int i = 0; i < 100; i++) {
            //提交100个任务，让调度服务执行
            scheduledExecutorService.submit(new CallableTest());
        }
    }

    @Override
    public String call(){
        System.out.println(Thread.currentThread().getName()+"执行call()");
        //call方法可以有返回值，这个在线程池中再详细说
        return "";
    }

}

